/*
 * @Author: zhouwei wei.zhou@flip.fun
 * @Date: 2024-04-02 20:02:56
 * @LastEditors: zhouwei wei.zhou@flip.fun
 * @LastEditTime: 2024-04-02 20:08:55
 * @FilePath: /50/手撕系列/instanceof.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/**
 * @description instanceof操作符
 * @description 作用: 检测右边的构造函数是否在左边实例对象的原型链
 * @param {*} left
 * @param {*} right
 */
function myInstanceof(left, right) {
	let leftPrototype = Object.getPrototypeOf(left)
	const rightPrototype = right.prototype
	while (true) {
		if (!leftPrototype) {
			return false
		}
		if (leftPrototype === rightPrototype) {
			return true
		}
		leftPrototype = Object.getPrototypeOf(leftPrototype)
	}
}
